package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.AppUserUpdateUserRoomStatusDTO;
import com.itlong.cloud.POJO.DTO.property.UserDeviceAuthAddreddDTO;
import com.itlong.cloud.property.service.IPropertyHouseHoldDeviceAuthService;
import com.itlong.cloud.user.property.IPropertyHouseHoldDeviceAuthServiceClient;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      用户设备权限服务暴露接口实现类。
 * </desc>
 *
 * @createDate 2017/10/18
 */
@RestController
public class PropertyHouseHoldDeviceAuthServiceResource implements IPropertyHouseHoldDeviceAuthServiceClient {
    private static final Logger LOG = LoggerFactory.getLogger(PropertyHouseHoldDeviceAuthServiceResource.class);

    @Autowired
    IPropertyHouseHoldDeviceAuthService iPropertyHouseHoldDeviceAuthService;

    /**
     * <desc>
     *      用户设备权限-获取用户权限地址
     * <desc/>
     *
     * @param userIdLists 权限变更的用户Id和对应项目Id的集合
     * @param projectId 项目Id
     * @param loginUserId 用户登录Id
     * @return List<UserDeviceAuthAddreddDTO> 用户权限地址数据传输对象集
     * @author zhangs
     * @createDate 2017/10/13
     */
    @RequestMapping(path = "manage/getUserAuthAddr", method = RequestMethod.POST)
    @Override
    public List<UserDeviceAuthAddreddDTO> getUserAuthAddr(
            @RequestBody List<Map<String, Object>> userIdLists,
            @RequestParam("projectId") String projectId,
            @RequestParam("loginUserId") String loginUserId) {
        return iPropertyHouseHoldDeviceAuthService.getUserAuthAddr(userIdLists, projectId, loginUserId);
    }

    /**
     * <desc>
     *      迁出住户时删除地址对应的其他类别的设备权限
     * <desc/>
     *
     * @param  appUserUpdateUserRoomStatusDTO 迁出App用户传输数据
     * @param  projectId 项目Id
     * @return
     * @author zhangs
     * @createDate 2017/11/2
     */
    @RequestMapping(path = "manage/delUserOtherAuth", method = RequestMethod.POST)
    @Override
    public void delUserOtherAuth(@RequestBody AppUserUpdateUserRoomStatusDTO appUserUpdateUserRoomStatusDTO,
                                 @RequestParam("projectId") String projectId) {
        iPropertyHouseHoldDeviceAuthService.delUserOtherAuth(appUserUpdateUserRoomStatusDTO, projectId);
    }
}
